package com.myapi.ModelPoker;
import java.util.Set;



//PartialHands are: pair, 3 of a kind, 4 of a kind
public class PartialHand extends RankedHand implements Comparable {
	private Card interestCard;
	
	public PartialHand(int rank, Set<Card> cards, Card interestCard) {
		super(rank, cards);	
		this.interestCard = interestCard;
	}
	
	private int getInterestCardValue() {
		return interestCard.getValue();		
	}
        
        public String rankToString() {
            String outRank = "";
            switch(getRank()) {
                case 1: outRank = "Pair"; break;
                case 3: outRank = "Three of a kind"; break;
                case 7: outRank = "Four of a kind"; break;                
            }
            return outRank;
        }
	
	public int compareTo(Object o) {
		assert o instanceof RankedHand;
		RankedHand hand = (RankedHand) o;
		int handRank = hand.getRank();
		if(getRank() > handRank) {
			return 1;
		} else if(getRank() < handRank) {
			return -1;
		} else {  //same rank, so must also be a PartialHand
			PartialHand pHand = (PartialHand) o;
			if(getInterestCardValue() > pHand.getInterestCardValue())
				return 1;
			else if(getInterestCardValue() < pHand.getInterestCardValue())
				return -1;
			else {  //look at kickers
				return compareHighCards(getCards(), hand.getCards());
			}			
		}
	}

}
